import { back } from './index';
export default {
    commitInit(state, payload) {
        const { k, v } = payload;
        if (!state.hasOwnProperty(k)) return;
        state[k] = v;
    },
    commitTypeData(state, payload) {
        const { k, data } = payload;
        if (!state[k]) return;
        Object.keys(data).forEach(item => {
            if (!state[k].hasOwnProperty(item)) return;
            state[k][item] = data[item];
        });
    },
    commitState(state, payload) {
        const { k, v } = payload;
        if (!state.hasOwnProperty(k)) return;
        state[k] = v;
    },
    backState(state, { k } = {}) {
        const newState = back();
        if (typeof k !== 'undefined') {
            state[k] = newState[k];
            return;
        }
        state = Object.assign(state, newState);
    },
};
